home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / CHIP Haziran 2001.iso / prog / share / 17 / dings_e.exe / Compiler / Include / stl_hash_fun.h < prev    next >
C/C++ Source or Header  |  1998-03-08  |  3KB  |  94 lines

  1. /*
  2.  * Copyright (c) 1996
  3.  * Silicon Graphics Computer Systems, Inc.
  4.  *
  5.  * Permission to use, copy, modify, distribute and sell this software
  6.  * and its documentation for any purpose is hereby granted without fee,
  7.  * provided that the above copyright notice appear in all copies and
  8.  * that both that copyright notice and this permission notice appear
  9.  * in supporting documentation.  Silicon Graphics makes no
  10.  * representations about the suitability of this software for any
  11.  * purpose.  It is provided "as is" without express or implied warranty.
  12.  *
  13.  *
  14.  * Copyright (c) 1994
  15.  * Hewlett-Packard Company
  16.  *
  17.  * Permission to use, copy, modify, distribute and sell this software
  18.  * and its documentation for any purpose is hereby granted without fee,
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both that copyright notice and this permission notice appear
  21.  * in supporting documentation.  Hewlett-Packard Company makes no
  22.  * representations about the suitability of this software for any
  23.  * purpose.  It is provided "as is" without express or implied warranty.
  24.  *
  25.  */
  26.  
  27. /* NOTE: This is an internal header file, included by other STL headers.
  28.  *   You should not attempt to use it directly.
  29.  */
  30.  
  31. #ifndef __SGI_STL_HASH_FUN_H
  32. #define __SGI_STL_HASH_FUN_H
  33.  
  34. #include <stddef.h>
  35.  
  36. __STL_BEGIN_NAMESPACE
  37.  
  38. template <class Key> struct hash { };
  39.  
  40. inline size_t __stl_hash_string(const char* s)
  41. {
  42.   unsigned long h = 0; 
  43.   for ( ; *s; ++s)
  44.     h = 5*h + *s;
  45.   
  46.   return size_t(h);
  47. }
  48.  
  49. __STL_TEMPLATE_NULL struct hash<char*>
  50. {
  51.   size_t operator()(const char* s) const { return __stl_hash_string(s); }
  52. };
  53.  
  54. __STL_TEMPLATE_NULL struct hash<const char*>
  55. {
  56.   size_t operator()(const char* s) const { return __stl_hash_string(s); }
  57. };
  58.  
  59. __STL_TEMPLATE_NULL struct hash<char> {
  60.   size_t operator()(char x) const { return x; }
  61. };
  62. __STL_TEMPLATE_NULL struct hash<unsigned char> {
  63.   size_t operator()(unsigned char x) const { return x; }
  64. };
  65. __STL_TEMPLATE_NULL struct hash<signed char> {
  66.   size_t operator()(unsigned char x) const { return x; }
  67. };
  68. __STL_TEMPLATE_NULL struct hash<short> {
  69.   size_t operator()(short x) const { return x; }
  70. };
  71. __STL_TEMPLATE_NULL struct hash<unsigned short> {
  72.   size_t operator()(unsigned short x) const { return x; }
  73. };
  74. __STL_TEMPLATE_NULL struct hash<int> {
  75.   size_t operator()(int x) const { return x; }
  76. };
  77. __STL_TEMPLATE_NULL struct hash<unsigned int> {
  78.   size_t operator()(unsigned int x) const { return x; }
  79. };
  80. __STL_TEMPLATE_NULL struct hash<long> {
  81.   size_t operator()(long x) const { return x; }
  82. };
  83. __STL_TEMPLATE_NULL struct hash<unsigned long> {
  84.   size_t operator()(unsigned long x) const { return x; }
  85. };
  86.  
  87. __STL_END_NAMESPACE
  88.  
  89. #endif /* __SGI_STL_HASH_FUN_H */
  90.  
  91. // Local Variables:
  92. // mode:C++
  93. // End:
  94.